<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 200px;
            height: 200px;
            background-color: pink;
            position: relative;

        }

        /* / 通过伪元素和缩放实现 0.5px border */
        .box1::after {
            position: absolute;
            content: "";
            left: 0;
            top: 0;
            width: 200%;
            height: 200%;
            background-color: yellow;
            border: 1px solid red;
            transform: scale(0.5);
            transform-origin: left top;
        }


        .box2 {
            width: 200px;
            height: 200px;
            background-color: pink;
            position: relative;
            margin-top: 20px;

        }

        /* / 通过伪元素和缩放实现 顶部1px边框 */
        .box2::after {
            position: absolute;
            content: "";
            left: 0;
            top: 0;
            width: 200%;
            height: 1px;
            background-color: red;

            transform: scale(0.5);
            transform-origin: left top;
        }
    </style>
</head>

<body>

    <div class="box1"></div>
    <div class="box2"></div>
</body>

</html>